﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace MW3Launcher
{
    public partial class aeroLable : UserControl
    {
        //Constructor
        public aeroLable()
        {
            InitializeComponent();
            this.Click += new EventHandler(aeroLable_Click);
            
        }

        void aeroLable_Click(object sender, EventArgs e)
        {
            if (ClickUrl != "" && ClickUrl!=null)
                System.Diagnostics.Process.Start(ClickUrl);
        }
        #region properties
        //lblText
        public string lblText
        {
            get { return intial_lable.Text; }
            set
            {
                if (InvokeRequired)
                {
                    this.Invoke(new MethodInvoker(delegate
                    {
                        intial_lable.Text = value; repaint(); Application.DoEvents();
                    }
                    ));
                }
                else
                {
                    intial_lable.Text = value; repaint(); Application.DoEvents();
                }

            }
        }
        public string ClickUrl { get; set; }
        //lblFont
        public Font lblFont
        {
            get { return intial_lable.Font; }
            set { intial_lable.Font = value; repaint(); }//
        }
        //lblForeColor
        public Color lblForeColor
        {
            get { return intial_lable.ForeColor; }
            set { intial_lable.ForeColor = value; repaint(); }
        }
        //lblGlowColor
        private Color _Glowcolor = Color.Empty;
        public Color lblGlowColor
        {
            get { return _Glowcolor; }
            set { _Glowcolor = value; repaint(); }
        }
        //lblAutoSize
        /* public bool lblAutoSize
         {
             get { return label1.AutoSize; }
             set { label1.AutoSize = value; repaint()}
         }*/
        //lbl Glow
        private bool _glow = true;
        public bool lblGlow
        {
            get { return _glow; }
            set { _glow = value; repaint(); }
        }
        //lbl_glowsize
        private int _glowsize = 10;
        public int GlowSize
        {
            get { return _glowsize; }
            set { _glowsize = value; repaint(); }
        }

        #endregion


        private void aeroLable_Resize(object sender, EventArgs e)
        {
            /*if (label1.AutoSize) 
                if (this.Size != label1.Size) 
                        this.Size = label1.Size;*/
            if (intial_lable.Size != this.Size) intial_lable.Size = this.Size;
        }

        private void label1_Resize(object sender, EventArgs e)
        {
            /*if (this.Size != label1.Size) this.Size = label1.Size;*/
        }

        public void repaint()
        {
            try
            {
                using (Graphics g = this.CreateGraphics())
                {
                    using (PaintEventArgs e = new PaintEventArgs(g, this.ClientRectangle))
                    {
                        aeroLable_Paint(this, e);
                    }
                }
            }
            catch { }
        }
        private void aeroLable_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(this.BackColor);
            e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
            e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            if (_glow && glass_helper.IsAeroGlassEnabled())
            {
                GlassText glasstxt = new GlassText();
                glasstxt.FillBlackRegion(e.Graphics, this.ClientRectangle);
                glasstxt.DrawTextOnGlass(this.Handle, intial_lable.Text, intial_lable.Font, intial_lable.Bounds, _glowsize, lblForeColor, lblGlowColor);
            }
            else
            {
                e.Graphics.DrawString(intial_lable.Text, intial_lable.Font, new SolidBrush(intial_lable.ForeColor), 0, 0);
            }
        }


    }
}
